<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <c:set var="ctx" value="${pageContext.request.contextPath}"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>挂靠公司变更记录</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<sys:funcAuth resCd="GSApply">
	<span id="GSApply" />
</sys:funcAuth>
<script type="text/javascript">
    var grid = null;
    var splId;
    linkId = '${linkId}';
    $(function () {
        var _url = '<%=path%>/project/prjLnkCompApply/initChangeList.do?lnkCompId=' + linkId;
        $("#ligergrid1").ligerGrid({
            url: _url,
            method: 'get',
            columns: [
                {display: '挂靠公司名称-变更前', name: 'befLnkCompNm', width: '15%'},
                {display: '挂靠公司名称-变更后', name: 'aftLnkCompNm', width: '15%'},
                {display: '统一社会信用代码-变更前', name: 'befSucc', width: '15%'},
                {display: '统一社会信用代码-变更后', name: 'aftSucc', width: '15%'},
                {display: '注册地址-变更前', name: 'befRegAddr', width: '15%'},
                {display: '注册地址-变更后', name: 'aftRegAddr', width: '15%'},
                {display: '企业类型-变更前', name: 'befCompTyp', width: '15%'},
                {display: '企业类型-变更后', name: 'aftCompTyp', width: '15%'},
                {display: '成立日期-变更前', name: 'befRegDt', width: '15%'},
                {display: '成立日期-变更后', name: 'aftRegDt', width: '15%'},
                {display: '经营范围-变更前', name: 'befBizScope', width: '15%'},
                {display: '经营范围-变更后', name: 'aftBizScope', width: '15%'},
                {display: '可支持挂靠项目类型-变更前', name: 'befSuppPrjTypCdNm', width: '15%'},
                {display: '可支持挂靠项目类型-变更后', name: 'aftSuppPrjTypCdNm', width: '15%'},
               	
                {display: '创建时间', name: 'crtTm', width: '15%', render: renderDate},
                getOperateColumn()
            ],
            pageSize: 10,
            root: 'data',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            rownumbers: true,
        });
        grid = liger.get("ligergrid1");
        grid.setHeight(100);
		
        var isShowCmtBtn = $("#GSApply");
        if(isShowCmtBtn.length){
        	$("#btnDiv").show();
		}
    });

    //显示流程
    function showFlow(_pInstId, _audStsCd, _businessKey) {
        if (StringUtils.isEmpty(_pInstId)) {
            UIUtils.alertWarning(CommonConstant.C_P_INSTANCEID_NOT_HERE);
            return;
        }
        var _formUrl = "/project/prjLnkCompBkAcc/toDetailPage.do?isFlow=1@@id=";
        var params = "?pInsId=" + _pInstId + "&status=" + _audStsCd + "&businessKey=" + _businessKey + "&formUrl=" + _formUrl;
        Add_navTab('tab_spl_bank_flow_' + _pInstId, '查看流程', "<%=path%>/flow/flow/toFlowShowPageFowBus.do" + params);
    }

    function getOperateColumn() {
        return {
            display: '操作', width: '15%',
            render: function (rowdata, rowindex, value) {
                var h = "";
                if (rowdata.audStsCd == 0) {
                    h += '<a class="sq-button-hasicon" href="javascript:startFlow(';
                    h += "'" + rowdata.id + "'";
                    h += ')"><i class="sqBtnIco_6"></i>发起审核流程</a>';
                }
                h += '<a class="sq-button-hasicon" href="javascript:showDetail(';

                h += "'" + rowdata.id + "',";
                h += "'" + rowdata.prjLnkCompId + "'";

                /*   h+="'"+rowdata.id+"','"+rowdata.prjLnkCompId+"'"; */
                h += ')"><i class="sqBtnIco_2"></i>查看变更详情</a>';
                return h;
            }
        };
    }

    //供应商变更详情
    function showDetail(_id, _prjLnkCompId) {
        if (!_id) return;
        Add_navTab('tab_spl_bsc_info_apply_' + _id, '挂靠公司变更记录 ', "<%=path%>/project/prjLnkCompApply/toComparePage.do?id=" + _id + "&prjLnkCompId=" + _prjLnkCompId);
    }

    //发起审核流程
    function startFlow(_id) {
        if (!_id) return;
        //发起流程确认
        $.ligerDialog.confirm(FlowConstant.FLOW_ADD_START_CONFIRM, function (flag) {
            if (flag == false) return;
            var modelTyp = FlowConstant.FLOW_MODEL_TYP_SPL_CHG;//流程业务分类-供应商信息变更
            if (StringUtils.isEmpty(modelTyp)) {
                console.log("modelTyp is null");
                return;
            }
            var flowDialog = $.ligerDialog.SQopen({
                url: '<%=path%>/flow/flow/toForStartListPage.do?modelTyp=' + modelTyp,
                width: 700,
                height: 400,
                title: '请选择要发起的流程',
                buttons: [{
                    text: "确定", type: 'ok', cls: 'l-dialog-btn-ok',
                    onclick: function (item, Dialog) {
                        if (Dialog.onOk) Dialog.onOk();
                    }
                }, {
                    text: "取消", type: 'cancel', cls: 'l-dialog-btn-no',
                    onclick: function (item, Dialog) {
                        if (Dialog.onCancel) Dialog.onCancel();
                    }
                }
                ],
                onClose: function () {
                    var json = flowDialog._DATA;
                    console.log(json);
                    if (!json) {
                        return;
                    }
                    var wait_dialog = $.ligerDialog.SQalert({
                        content: LogUtils.LOG_CMM_DATA_LOADING,
                        SQ_type: "waitting",
                        onClose: function () {
                        }
                    });
                    $.ajax({
                        type: 'post',
                        dataType: 'json',
                        data: {
                            id: _id,
                            procDefKey: json.procDefKey,
                            procDefId: json.procDefId,
                            procNo: json.procNo
                        },
                        url: '<%=path%>/project/prjLnkCompBkAcc/addFlowStart.do',
                        success: function (msg) {
                            wait_dialog.close();
                            if (msg.success == 1) {
                                UIUtils.alertSuccessHold1(msg.info);
                                /* if(lxxz=="true"){
                                   Remove_navTab();
                                   return;
                                } */
                                grid.reload();
                            } else {
                                UIUtils.alertErrorHold1(msg.info);
                            }
                        }
                    });
                }
            });
        });
    }

    function iframeResize() {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        }
        ;
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }
    
    function addFlowStart(){
    	 $.ajax({
             type: 'post',
             dataType: 'json',
             data: {
            	 lnkCompId: linkId,
             },
             url: '<%=path%>/project/prjLnkCompApply/addLnkCompApplyFlow.do',
             beforeSend: function () {
                 wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
             },
             success: function (msg) {
                 wait_dialog.close();
                 if (msg.success == 1) {
                 	$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                     grid.reload();
                 } else {
                     UIUtils.alertErrorHold1(msg.info);
                     grid.reload();
                 }
             }
         });
    }

</script>

<body class="iframeBody">
<div class="Wrapper">
</div>
<div class="btnsBox">
<div class="btnsBox" id="btnDiv">
	<sys:funcAuth resCd="GSApply">
		<!-- 2020-06-10 12:44:37 三方数据关停-->
		<%--<span id="prj_lnk_comp_add_btn_id"
			  class="sq-button sq-button-round" id="GSApply" onclick="addFlowStart();">执行工商变更
		</span>--%>
	</sys:funcAuth>
</div>
<div id="ligergrid1" class="sq-grid"></div>
</body>
</html>